package Dao;

import Model.StudentCourse;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * Created by zhnh9 on 12/4/2016.
 */
public class TwoPara extends BaseDao<StudentCourse> {
    private StudentCourse changeName = new StudentCourse();



    /**
     * 更改学生姓名
     * @author 赵文赫
     * @param oldName 原先的姓名
     * @param newName 新姓名
     */
    public void renameStudent(String oldName, String newName) {
        String sql = "UPDATE student_course SET student = ? WHERE student = ? ";
        changeName.setName(oldName);
        changeName.setNameNew(newName);
        alter(sql, changeName);
    }


    /**
     * 传两个parameter，单独成类
     * @author 赵文赫
     * @param preparedStatement
     * @param Object
     */
    @Override
    public void insert(PreparedStatement preparedStatement, StudentCourse Object) {
        try {
            preparedStatement.setString(1, Object.getNameNew());
            preparedStatement.setString(2, Object.getName());

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    /**
     * 在这个类中这个方法没用，但是还是要实例出来
     * @param resultSet
     * @return
     */
    @Override
    public StudentCourse setObjectByResultSet(ResultSet resultSet, int count) {
        return null;
    }
}
